package fr.grobim.hangovers.gestionBudget.beans.factures;

import java.util.Date;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import fr.grobim.hangovers.gestionBudget.beans.comptes.Membre;

@Entity
@Table(name = "reglement_facture")
public class ReglementFacture {
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "id")
	private Integer id;
	
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "id_facture", nullable = false)
	private Facture facture;
	
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "id_payeur", nullable = false)
	private Membre payeur;
	
	@Temporal(TemporalType.DATE)
	@Column(name = "datePayement", nullable = false)
	private Date datePayement;
	
	@Column(name = "prix", nullable = false)
	private Double prix;
	
	@ManyToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
	@JoinTable(name = "reglements_membres_concernes", joinColumns = {
		@JoinColumn(name = "id_reglement", nullable = false, updatable = false)},
		inverseJoinColumns = {@JoinColumn(name = "id_membre", nullable = false,
		updatable = false) })
	private Set<Membre> membreConcernes;

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public Facture getFacture() {
		return facture;
	}

	public void setFacture(Facture facture) {
		this.facture = facture;
	}

	public Membre getPayeur() {
		return payeur;
	}

	public void setPayeur(Membre payeur) {
		this.payeur = payeur;
	}

	public Date getDatePayement() {
		return datePayement;
	}

	public void setDatePayement(Date datePayement) {
		this.datePayement = datePayement;
	}

	public Double getPrix() {
		return prix;
	}

	public void setPrix(Double prix) {
		this.prix = prix;
	}

	public Set<Membre> getMembreConcernes() {
		return membreConcernes;
	}

	public void setMembreConcernes(Set<Membre> membreConcernes) {
		this.membreConcernes = membreConcernes;
	}

}
